Landsat8 product

Landsat8 product stage-in example.

Import the Python packages

[1]:
%matplotlib inline

import warnings
warnings.filterwarnings("ignore")
import os
import sys
import glob
os.environ['_CIOP_APPLICATION_PATH']=''
sys.path.append('/opt/anaconda/bin/')
import cioppy
ciop = cioppy.Cioppy()

import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.colors as colors

from snappy import jpy
from snappy import ProductIO
from snappy import GPF
from snappy import HashMap

import gc

from shapely.wkt import loads

Search parameters

Set the catalogue endpoint to Sentinel-1:

[2]:
series = 'https://catalog.terradue.com/landsat8/search'

Define the time of interest:

[3]:
start_date = '2017-09-01T00:00:00'
stop_date = '2017-12-10T23:59:59'

Define the area of interest:

[4]:
geom = 'MULTIPOLYGON (((6.4788 14.5973, 7.5577 14.5973, 7.5577 13.6328, 6.4788 13.6328, 6.4788 14.5973)), ((67.7116 37.9032, 68.791 37.9032, 68.791 36.9211, 67.7116 36.9211, 67.7116 37.9032)), ((-10.3668 15.3471, -9.351800000000001 15.3471, -9.351800000000001 14.3406, -10.3668 14.3406, -10.3668 15.3471)), ((67.62430000000001 36.7228, 68.116 36.7228, 68.116 35.6923, 67.62430000000001 35.6923, 67.62430000000001 36.7228)))'

Check the WKT validity:

[5]:
loads(geom)
[5]:
../../../../../../_images/solutions_notebooks_quick-start_resources_code_hands-on-2_Landsat8_-_stage-in_11_0.svg

Stage-in the data

Define the local folder where to stage-in the data to:

[13]:
data_path = os.path.join(os.sep,'workspace','tmp','data')
[14]:
if not os.path.isdir(data_path):
    os.makedirs(data_path)
[15]:
try:
    retrieved = ciop.copy(search[ls8_index]['enclosure'], data_path)
except:
    retrieved = os.path.join(data_path, search[ls8_index]['identifier'])
[18]:
product_path = os.path.join(data_path, ls8_identifier)

if not os.path.isdir(product_path):
    os.makedirs(product_path)

os.chdir(product_path)

import tarfile
tar = tarfile.open(retrieved)
tar.extractall()
tar.close()

List Archive content

[19]:
products = [ name for name in os.listdir('.') ]

products
[19]:
['LC08_L1TP_154033_20171210_20180525_01_T1_ANG.txt',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B1.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B10.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B11.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B2.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B3.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B4.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B5.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B6.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B7.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B8.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_B9.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_BQA.TIF',
 'LC08_L1TP_154033_20171210_20180525_01_T1_MTL.txt']